import { FormSchema } from '/@/components/Form';
import { getUsersByDepId } from './depart.api';

import { render } from '/@/utils/common/renderUtils';
import { h } from 'vue';
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
// 部门基础表单
export function useBasicFormSchema() {
  const basicFormSchema: FormSchema[] = [
    {
      field: 'departName',
      label: '机构名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入机构/部门名称',
      },
      rules: [{ required: true, message: '机构名称不能为空' }],
    },
    {
      field: 'parentId',
      label: '上级部门',
      component: 'TreeSelect',
      componentProps: {
        treeData: [],
        placeholder: '无',
        dropdownStyle: { maxHeight: '200px', overflow: 'auto' },
      },
    },
    {
      field: 'orgCode',
      label: '机构编码',
      component: 'Input',
      componentProps: {
        placeholder: '请输入机构编码',
      },
    },
    {
      field: 'orgCategory',
      label: '机构类型',
      component: 'RadioButtonGroup',
      componentProps: { options: [] },
    },
    // {
    //   label: '部门负责人',
    //   field: 'id',
    //   required: true,
    //   component: 'ApiSelect',
    //   componentProps:{
    //     mode: 'multiple',
    //     //配置是否可搜索
    //     showSearch: true
    //     api: getUsersByDepId,
    //     // api:()=> defHttp.get({ url: '/sys/user/queryUserByDepId',param: { id: '1752127059246723073' } }),
    //     //请求参数
    //     // params: {id: 'id' },
    //     params: { id: '1752127059246723073' },
    //     labelField: 'realname',
    //     valueField: 'username',
    //     immediate: false,
    //   },
    //   // rules: [{ required: true, message: '部门负责人不能为空' }],
    // },

    {
      label: '部门负责人',
      field: 'userCusSelect',
      component: 'UserSelect',
      componentProps: {
        //是否多选
        multi: true,
        //从用户表中选择一列，其值作为该控件的存储值，默认id列
        store: 'id',
        //是否排除我自己(当前登录用户)
        izExcludeMy: false,
        //是否禁用
        disabled: false,
      },
    },


  //   {
  //     label: '三级部门',
  //     field: 'key',
  //     component: 'ApiSelect',
  //     componentProps: ({ formModel }) => {
  //     return {
  //         api: getUsersByDepId,
  //         resultField: 'list',
  //         labelField: 'realname',
  //         params: {
  //             id: formModel.id,
  //         },
  //         valueField: 'username',
  //         immediate: false,
  //     }
  //   }
  // },


    // {
    //   field: 'keya',
    //   label: '条件规则',
    //   required: true,
    //   component: 'ApiSelect',
    //   componentProps: {
    //     api: getUsersByDepId,
    //     params: { id: '1737017147540979714'},
    //     labelField: 'realname',
    //     valueField: 'username',
    //     getPopupContainer: (node) => document.body,
    //   },
    // },
    {
      field: 'departOrder',
      label: '排序',
      component: 'InputNumber',
      componentProps: {},
    },
    {
      field: 'mobile',
      label: '电话',
      component: 'Input',
      componentProps: {
        placeholder: '请输入电话',
      },
    },
    {
      field: 'fax',
      label: '传真',
      component: 'Input',
      componentProps: {
        placeholder: '请输入传真',
      },
    },
    {
      field: 'address',
      label: '地址',
      component: 'Input',
      componentProps: {
        placeholder: '请输入地址',
      },
    },
    {
      field: 'memo',
      label: '备注',
      component: 'InputTextArea',
      componentProps: {
        placeholder: '请输入备注',
      },
    },
  ];
  return { basicFormSchema };
}

// 机构类型选项
export const orgCategoryOptions = {
  // 一级部门
  root: [{ value: '1', label: '公司' }],
  // 子级部门
  child: [
    { value: '2', label: '部门' },
    { value: '3', label: '岗位' },
  ],
};
